package com.example.liuhb.h5;

import android.app.AlertDialog;
import android.content.Context;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

/**
 * Created by liu.hb on 2018/6/22.
 */

public class MyObject {
    Context context;
    String json ;

    public MyObject(Context context) {
        this.context = context;
    }
    //js调用安卓原生
    @JavascriptInterface
    public void showToast(String name){
        Toast.makeText(context,name,Toast.LENGTH_SHORT).show();
    }
    @JavascriptInterface
    public void showDialog(String name){
        System.out.println("name:"+name);
        this.json = name;
       new AlertDialog.Builder(context).setTitle("信息").setMessage(name).show();
    }

}
